﻿<Window x:Class="Poet.Views.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        xmlns:avalondock="http://avalondock.codeplex.com"
        Icon="/Avalon;component/../Icons/Rose_32x32.png"
        Title="Poet" Width="966" Height="600"
        WindowStartupLocation="CenterScreen" 
        ResizeMode="CanResizeWithGrip">

  <Window.InputBindings>
    <KeyBinding Key="S" Modifiers="Ctrl+Shift" Command="{Binding SaveAll}"/>
  </Window.InputBindings>

  <Window.Resources>

    <ContextMenu x:Key="TrayMenu">
      <MenuItem Header="Hide" />
      <MenuItem Header="Topmost" IsCheckable="True" IsChecked="{Binding Topmost}"/>
      <MenuItem Header="Tool Style" IsCheckable="true" Tag="ToolStyle"/>
      <Separator />
      <MenuItem Header="Exit"  />
    </ContextMenu>
    <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
  </Window.Resources>

  <Grid>
    <Grid.RowDefinitions>
      <RowDefinition Height="Auto"/>
      <RowDefinition Height="Auto"/>
      <RowDefinition Height="*"/>
      <RowDefinition Height="Auto"/>
    </Grid.RowDefinitions>

    <Menu>

      <Menu.Resources>
        <Style TargetType="{x:Type Image}">
          <Style.Triggers>
            <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type MenuItem}, AncestorLevel=1}, Path=IsEnabled}" Value="False">
              <Setter Property="Opacity" Value="0.30" />
            </DataTrigger>
          </Style.Triggers>
        </Style>
      </Menu.Resources>

      <MenuItem Header="{Localizing File}">
        <MenuItem Header="{Localizing New}" Command="New" Icon="{Picture Icons/New_16x16.png, 16}"/>
        <MenuItem Header="{Localizing Open}" Command="Open" Icon="{Picture Icons/Open_16x16.png, 16}"/>
        <Separator/>
        <MenuItem Header="{Localizing Save}" Command="Save" Icon="{Picture Icons/Save_16x16.png, 16}"/>
        <MenuItem Header="{Localizing SaveAs}" Command="SaveAs"/>
        <MenuItem Header="{Localizing SaveAll}" Command="{Binding SaveAll}" Icon="{Picture Icons/SaveAll_16x16.png, 16}"/>
        <Separator/>
        <MenuItem Header="{Localizing Close}" Command="Close"/>
        <MenuItem Header="{Localizing CloseAll}" Command="{Binding CloseAll}" Icon="{Picture Icons/Close_16x16.png, 16}"/>
        <Separator/>
        <MenuItem Header="{Localizing PageSetup}"  Icon="{Picture Icons/PageSetup_16x16.png, 16}"/>
        <MenuItem Header="{Localizing Print}" Command="Print" Icon="{Picture Icons/Print_16x16.png, 16}"/>
        <Separator/>
        <MenuItem Header="{Localizing Recent}"/>
        <MenuItem Header="{Localizing Pinned}"/>
        <Separator/>
        <MenuItem Header="{Localizing Exit}" Command="{Binding Exit}" Icon="{Picture Icons/Exit_16x16.png, 16}"/>
      </MenuItem>

      <MenuItem Header="{Localizing Edit}">
        <MenuItem Header="{Localizing Undo}" Command="Undo" Icon="{Picture Icons/Undo_16x16.png, 16}"/>
        <MenuItem Header="{Localizing Redo}" Command="Redo" Icon="{Picture Icons/Redo_16x16.png, 16}"/>
        <Separator/>
        <MenuItem Header="{Localizing Cut}" Command="Cut" Icon="{Picture Icons/Cut_16x16.png, 16}"/>
        <MenuItem Header="{Localizing Copy}" Command="Copy" Icon="{Picture Icons/Copy_16x16.png, 16}"/>
        <MenuItem Header="{Localizing Paste}" Command="Paste" Icon="{Picture Icons/Paste_16x16.png, 16}"/>
        <MenuItem Header="{Localizing Delete}" Command="ApplicationCommands.Delete" Icon="{Picture Icons/Delete_16x16.png, 16}"/>
        <Separator/>
        <MenuItem Header="{Localizing SelectAll}" Command="SelectAll" Icon="{Picture Icons/Delete_16x16.png, 16}"/>
      </MenuItem>

      <MenuItem Header="{Localizing Content}">
        <MenuItem Header="{Localizing Documents}"/>
        <MenuItem Header="{Localizing Tools}"/>
        <Separator/>
        <MenuItem Header="{Localizing Navigator}"/>
      </MenuItem>

      <MenuItem Header="{Localizing Format}">

      </MenuItem>

      <MenuItem Header="{Localizing View}">

      </MenuItem>

      <MenuItem Header="{Localizing Help}">
        <MenuItem Header="{Localizing ViewHelp}" Command="Help"/>
        <Separator/>
        <MenuItem Header="{Localizing About}" Command="{Binding About}"/>
      </MenuItem>

    </Menu>

    <ToolBarTray Grid.Row="1" Name="ToolBarTray">

            <ToolBar Name="StandartToolBar" 
                     Visibility="{Binding Path=ShowStandartToolBar,  Mode=TwoWay, Converter={StaticResource ResourceKey=BooleanToVisibilityConverter}}" 
                     PreviewGotKeyboardFocus="ToolBarPreviewGotKeyboardFocus" LostKeyboardFocus="ToolBarLostKeyboardFocus">

        <ToolBar.Resources>
          <Style TargetType="{x:Type Image}">
            <Style.Triggers>
              <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type ButtonBase}, AncestorLevel=1}, Path=IsEnabled}" Value="False">
                <Setter Property="Opacity" Value="0.30" />
              </DataTrigger>
            </Style.Triggers>
          </Style>
        </ToolBar.Resources>

        <Button Command="New" Content="{Picture Icons/New_16x16.png, 16}" ToolTip="{Localizing NewToolTip}"/>
        <Button Command="Open" Content="{Picture Icons/Open_16x16.png, 16}" ToolTip="{Localizing NewToolTip}"/>
        <Button Command="Save" Content="{Picture Icons/Save_16x16.png, 16}" ToolTip="{Localizing NewToolTip}"/>
        <Button Command="{Binding SaveAll}" Content="{Picture Icons/SaveAll_16x16.png, 16}" ToolTip="{Localizing NewToolTip}"/>
        <Separator/>
        <Button Command="Cut" Content="{Picture Icons/Cut_16x16.png, 16}" ToolTip="{Localizing NewToolTip}"/>
        <Button Command="Copy" Content="{Picture Icons/Copy_16x16.png, 16}" ToolTip="{Localizing NewToolTip}"/>
        <Button Command="Paste" Content="{Picture Icons/Paste_16x16.png, 16}" ToolTip="{Localizing NewToolTip}"/>
        <Button Command="ApplicationCommands.Delete" Content="{Picture Icons/Delete_16x16.png, 16}" ToolTip="{Localizing NewToolTip}"/>
        <Separator/>
        <Button Command="Undo" Content="{Picture Icons/Undo_16x16.png, 16}" ToolTip="{Localizing UndoToolTip}"/>
        <Button Command="Redo" Content="{Picture Icons/Redo_16x16.png, 16}" ToolTip="{Localizing RedoToolTip}"/>

      </ToolBar>

    </ToolBarTray>

        <avalondock:DockingManager Grid.Row="2"
                                   Name="DockingManager"
                                   AllowMixedOrientation="True"
                                   DocumentsSource="{Binding DocumentViews}">
            <avalondock:DockingManager.Resources>
                <Style TargetType="{x:Type avalondock:LayoutAnchorableItem}">
                    <Setter Property="Title" Value="{Binding Title}"/>
                    <Setter Property="IconSource" Value="{Binding Model.IconSource}"/>
                    <Setter Property="Visibility" Value="{Binding Model.IsVisible, Mode=TwoWay, Converter={StaticResource BoolToVisibilityConverter}, ConverterParameter={x:Static Visibility.Hidden}}"/>
                    <Setter Property="ContentId" Value="{Binding Model.ContentId}"/>
                    <Setter Property="IsSelected" Value="{Binding Model.IsSelected, Mode=TwoWay}"/>
                    <Setter Property="IsActive" Value="{Binding Model.IsActive, Mode=TwoWay}"/>
                </Style>
                <Style TargetType="{x:Type avalondock:LayoutItem}">
                    <Setter Property="Title" Value="{Binding Path=Context.DataContext.Title}"/>
                    <Setter Property="ToolTip" Value="{Binding Model.FilePath}"/>
                    <Setter Property="CloseCommand" Value="{Binding Model.CloseCommand}"/>
                    <Setter Property="IconSource" Value="{Binding Model.IconSource}"/>
                    <Setter Property="ContentId" Value="{Binding Model.ContentId}"/>
                </Style>

            </avalondock:DockingManager.Resources>
        </avalondock:DockingManager>

        <StatusBar Name="StatusBar" Grid.Row="3">

            <StatusBarItem Content="{Binding ElementName=DockingManager, Path=ActiveDocument.DataContext.Title}" Width="{Binding ElementName=StatusBar, Path=Width}"/>
            <Separator HorizontalAlignment="Right" HorizontalContentAlignment="Right"/>
            <StatusBarItem Name="LineNumberStatusBarItem" HorizontalAlignment="Right">
                <StackPanel Orientation="Horizontal">   
                    <TextBlock Text="{Localizing Ln, StringFormat=' {0}   '}"/>
                    <TextBlock Text="{Binding ElementName=DockingManager, Path=ActiveDocument.DataContext.TextEditor.TextArea.Caret.Line}"/>
                    <TextBlock Text="{Localizing Col, StringFormat=' {0}    '}"/>
                    <TextBlock Text="{Binding ElementName=DockingManager, Path=ActiveDocument.DataContext.TextEditor.TextArea.Caret.Column}"/>
                    <TextBlock Text="       "/>
                </StackPanel>
            </StatusBarItem>


        </StatusBar>
    </Grid>
</Window>
